import {v4} from 'uuid'

export function getUserTempId(){
    //尝试从local中读取用户临时标识
    const userTempId = localStorage.getItem('userTempId')
    if (userTempId) {
        return userTempId
    }else{
        const newUserTempId = v4();
        localStorage.setItem('userTempId', newUserTempId)
        return newUserTempId
    }
}
//保存用户token到localStorage中
export function saveToken(token) {
    return localStorage.setItem('token', token)
}
//从localStorage中读取数据
export function getToken(){
    return localStorage.getItem('token')
}

//清除token
export function deleteToken(){
    localStorage.removeItem('token')
}